package com.googlecode.uipipedream;

import java.awt.Color;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @author <a>James Jones</a>
 * @version 1.0 
 */
public class CSSGenerator {
	
	public CSSGenerator(){
		
	}
	
	public static void main(String[] args) {
		CSSGenerator cssg = new CSSGenerator();
		cssg.generateCSS(Color.BLUE, Color.ORANGE, Color.GREEN, Color.MAGENTA, Color.YELLOW);
	}

	public void generateCSS(Color c1, Color c2, Color c3, Color c4, Color c5 ){
		
		String str1 = null;
		String str2 = null;
		String str3 = null;
		String str4 = null;
		String str5 = null;
		String str6 = null;
		String str7 = null;
		String str8 = null;
		String str9 = null;
		String str10 = null;
		
		int r1 = c1.getRed();
		int g1 = c1.getGreen();
		int b1 = c1.getBlue();
		int r2 = c2.getRed();
		int g2 = c2.getGreen();
		int b2 = c2.getBlue();
		int r3 = c3.getRed();
		int g3 = c3.getGreen();
		int b3 = c3.getBlue();
		int r4 = c4.getRed();
		int g4 = c4.getGreen();
		int b4 = c4.getBlue();
		int r5 = c5.getRed();
		int g5 = c5.getGreen();
		int b5 = c5.getBlue();
		
		FileWriter fileWriter = null;
		
		try {
			fileWriter = new FileWriter("generatedCSS/style.css");
		} catch (IOException e) {
			e.printStackTrace();
		}

		BufferedWriter buffWriter = new BufferedWriter(fileWriter);
		str1 = "body\n{\n background-color: DimGray;\n"+
		" font-family: sans-serif;\n text-align: center;\n width: 100%;\n margin: auto;\n" +
		"\n font-size: 80%pt;\n}";
		
		str2 = "h1\n{\n color: red;\n}";
		
		str3 = "table\n{\n width: 95%;\n height:8%;\n Background: White;\n text-align:center;\n margin: auto;\n}";
		
		str4 = "a\n{\n font-weight: bold;\n color: Black;\n font-size: 250%;\n}" +
				"\np\n{\n color: rgb("+r4+","+g4+","+b4+");\n font-size: 100%pt;\n}";
		
		str5 = "#banner\n{\n height: 20%;\n background-position: center;\n width: 90%;\n margin: auto;" +
				"\n background-color: DimGray;\n}";
		
		str6 = "#gap1\n{\n height: 15%;\n background-position: center;\n width: 100%;\n margin: auto;" +
		"\n background-color: DimGray;\n}";
		
		str7 = "#blackSquare\n{\n height: 15%;\n background-position: center;\n width: 98%;\n margin: auto;" +
		"\n background-color: rgb("+0+","+0+","+0+");\n}";
		
		str10 = "#c1\n{\n height: 50%;\n width: 70%;" +
		"\n background-color: rgb("+r1+","+g1+","+b1+");\n margin: auto;\n}\n"
		+ "#c2\n{\n height: 50%;\n width: 70%;" +
		"\n background-color: rgb("+r2+","+g2+","+b2+");\n margin: auto;\n}\n"
		+ "#c3\n{\n height: 50%;\n width: 70%;" +
		"\n background-color: rgb("+r3+","+g3+","+b3+");\n margin: auto;\n}\n"
		+ "#c4\n{\n height: 50%;\n width: 70%;" +
		"\n background-color: rgb("+r4+","+g4+","+b4+");\n margin: auto;\n}\n"
		+ "#c5\n{\n height: 50%;\n width: 70%;" +
		"\n background-color: rgb("+r5+","+g5+","+b5+");\n margin: auto;\n}\n";
		
		str8 = "#gap2\n{\n height: 15%;\n background-position: center;\n width: 100%;\n margin: auto;" +
		"\n background-color: DimGray;\n}";
		
		str9 = "#whiteSquare\n{\n height: 15%;\n background-position: center;\n width: 98%;\n margin: auto;" +
		"\n background-color: rgb("+255+","+255+","+255+");\n}";
		
		
		
		try {
			buffWriter.write(str1);
			buffWriter.newLine();
			buffWriter.write(str2);
			buffWriter.newLine();
			buffWriter.write(str3);
			buffWriter.newLine();
			buffWriter.write(str4);
			buffWriter.newLine();
			buffWriter.write(str5);
			buffWriter.newLine();
			buffWriter.write(str6);
			buffWriter.newLine();
			buffWriter.write(str7);
			buffWriter.newLine();
			buffWriter.write(str8);
			buffWriter.newLine();
			buffWriter.write(str9);
			buffWriter.newLine();
			buffWriter.write(str10);
			
			buffWriter.close();
			System.out.println("Completed CSS file generation");
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}
